Hello guys!
This article is the fifth part of this series. Let's see what I have in my bag this time for you guys regarding Python.
Getting Theme
For getting the theme of Python, kindly go through my previous article:
Introduction
In this part of this article series I am explaining multiline statements and parameter passing in Python. So let's explore it one by one.
Multiline Statements
A famous quote states:
“New day, a new beginning.”
Python also follows that. How?
Let me tell you, statements in Python typically end with a new line but if you feel like continuing on the same line then you can also do that using a line character called Line Continuation Character.
Structure
- Productlist = prod1 + \
- prod2+ \
- prod3 +
Example
- print ("Myself Abhishek a " + \
-
- "Geek | " + \
-
- "Student | " + \
-
- "Philanthropist | " + \
-
- "Painter | " + \
-
- "Tech Evanglist")
Output
As we know, there are alternate ways of doing the same thing and so as in Python. Let's have a look how.
Example 1
Languages = [‘.NET’, ‘HTML5’, ‘AngularJS’, ‘CSS3’, ‘Python’]
Example 2
Socialnetworks = {‘Linkedin’, ‘Facebook’, ‘Twitter’, ‘Google+’, ‘MySpace’}
So, we can easily conclude from the above two examples:
“In Python, we can also use brackets like [], {}, () to continue with the same line.”
These brackets can be also defined as the continuation character (maybe something else).
Parameter Passing
There are two types of parameter passing:
- Call by Value
- Call By Reference
Call By Value
The most common strategy of parameter or argument passing is call-by-value, sometimes it is also called pass-by-value. This strategy is used in several programming languages, like C, C#, Java, C++ and so on.
In the call by value approach, the argument expression is evaluated first and the result of this evaluation is bound to the corresponding variable in the function. So, if the expression is a variable, a local replica of its value will be used.
Here's a functionality.
(If you didn't get the theme then don't worry, I'll explain it in detail further in this article series.)
Call By Reference
In the call by reference approach, a function gets an implicit reference to the argument rather than a copy of its value. As a result, the function can modify the argument and the value of the variable in the caller's scope can be changed.
This strategy is also known as pass by reference and used in several programming languages, like C, C#, Java, C++ and so on.
The advantage of the call by reference is greater time and space efficiency because arguments do not need to be copied.
Here's a sample functionality:
(If you didn't get the theme then don't worry I'll explain it in detail, further in this article series.)
Guidelines
The following are some guidelines from my side:
- Do as much code you can.
- Code anything you want, that is the best way to learn
- Don't just study things, try to learn them.
- Work on your concepts
- Work on the fundamentals of any technology or stuff you want to learn.
Moto
“Keep calm and code Python”.
I tried to make this an interesting and interactive article and I wish you guys like that, meanwhile, if you have any suggestions then your welcome.
Until the next part, keep sharing!